﻿namespace MicroCloud.Authorization.Database
{
    #region "数据角色信息数据实体映射配置"
    /// <summary>
    /// 数据角色信息数据实体映射配置
    /// </summary>
    public class EntityRoleConfiguration : EntityTypeConfigurationBase<EntityRole, long>
    {
        #region "方法"
        #region "重写以实现实体类型各个属性的数据库配置"
        /// <summary>
        /// 重写以实现实体类型各个属性的数据库配置
        /// </summary>
        /// <param name="builder">实体类型创建器</param>
        public override void Configuration(EntityTypeBuilder<EntityRole> builder)
        {
            builder.HasIndex(m => new { m.EntityId, m.RoleId, m.Operation }).SetIndex("EntityRoleOperation", true);

            //builder.HasOne(er => er.EntityInfo).WithMany().HasForeignKey(m => m.EntityId).HasConstraintName($"FK_{EntityName}_EntityId").IsRequired();
            //builder.HasOne(er => er.Role).WithMany().HasForeignKey(m => m.RoleId).HasConstraintName($"FK_{EntityName}_RoleId").IsRequired();
            //builder.HasOne(er => er.EntityInfo).WithMany().HasForeignKey(m => m.EntityId).SetForeignKey($"EntityId");
            //builder.HasOne(er => er.Role).WithMany().HasForeignKey(m => m.RoleId).SetForeignKey($"RoleId");

            //builder.HasQueryFilter(o => o.Role.DeletedTime == null);

            ConfigurationAppend(builder);
        }
        #endregion

        #endregion

    }
    #endregion

}
